package com.usian.service.imp;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.usian.entity.PageResult;
import com.usian.entity.QueryPageBean;
import com.usian.mapper.DeptMapper;
import com.usian.mapper.EmpMapper;
import com.usian.mapper.UserMapper;
import com.usian.mapper.ZhiWuMapper;
import com.usian.pojo.*;
import com.usian.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImp implements EmpService {
    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private DeptMapper deptMapper;

    @Autowired
    private ZhiWuMapper zhiWuMapper;
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<Vo> findAll() {
        return empMapper.findAll();
    }



    @Override
    public void update(Emp emp) {
        empMapper.updateById(emp);
    }

    @Override
    public void add(Emp emp) {
        empMapper.insert(emp);
    }

    @Override
    public Emp findById(Integer eid) {
        return empMapper.selectById(eid);
    }

    @Override
    public void delete(String eid) {
        empMapper.deleteById(eid);
    }

    @Override
    public List<Dept> findDept() {
        return deptMapper.selectList(null);
    }

    @Override
    public List<ZhiWu> findZhiWu() {
        return zhiWuMapper.selectList(null);
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<Vo> page=empMapper.findPage(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(),page.getResult());
    }

}
